import Vuex from 'vuex'

import Vue from 'vue'

import "../api/axios"

Vue.use(Vuex)

const actions = {
    // 进入后台控制模式 
    toAdmin(context, value) {
        context.commit("TOADMIN", value)
    }
}
const mutations = {
    TOADMIN(state, value) {
        state.adminState = value;
        state.mainSm = 12
    },
    TOMAIN(state, value) {
        state.adminState = value;
        state.mainSm = 8
    },
    TAGTOMAIN(state, value) {

        state.pageCount = value;

    },
    CHANGGELIST(state, arcticle) {

        state.arcticleListUrl = arcticle.url
        state.arcticleListRouter = arcticle.router
        state.currentPage = 1
    },
    // 左边栏选择tagid后 保存在这个地方，tagGroup显示的时候选择这个id做高亮显示
    CHANGETAGID(state, id) {
        state.tagid = id
    }

}
const state = {
    adminState: false,
    mainSm: 8,
    pageCount: null,
    arcticleListUrl: "/arcticle/getArcticlePage",
    arcticleListRouter: "ArticleList",
    currentPage: 1,
    tagid: 0
}

export default new Vuex.Store({
    actions,
    mutations,
    state
})
